<?php 
extract($_GET);
$act = ( isset($act) ) ? $act : null;
$app = ( isset($app) ) ? $app : null;
$type = ( isset($type) ) ? $type : null;
$status = ( isset($status) ) ? $status : null;
$answers = ( isset($answers) ) ? $answers : null;
$order = ( isset($order) ) ? $order : null;
$list = ( isset($list) ) ? $list : null;
$sort = ( isset($sort) && $sort == 'asc' ) ? 'asc' : 'desc';
$d_sort = ( isset($sort) && $sort == 'asc' ) ? 'desc' : 'asc';

// If Login Page
if( $act == 'login' )
{
	require_once("pages/login.php");
} 
else if ( $act == 'logout' )
{
    header("Location: ?act=login");
    exit();
}
else 
{
	require_once("pages/header.php");       
    
    // If Media Component
    if( $type == 'media' )
    {
        require_once("pages/media.php");
    }
    
    // Manager
    else if( $type == 'manage' )
    {
        if( $act == 'new' )
        {
            require_once("pages/manage/new.php");
        }
        elseif( $act == 'edit' )
        {
            require_once("pages/manage/edit.php");
        }
        elseif( $act == 'apps' )
        {
            require_once("pages/manage/apps.php");
        }
        elseif( $list == 'users' )
        {
            require_once("pages/manage/userlist.php");
        }
        elseif( $list == 'apps' )
        {
            require_once("pages/manage/appslist.php");
        }
        else 
        {
            require_once("pages/manage/index.php");
        }
    }

    // Password
    else if ( $act == 'password' )
    {
        require_once("pages/password.php");
    }
    
    // Landing
    else if ( $app == 'landing' )
    {
        if( $act == 'settings' )
        {
            require_once("pages/landing/settings.php");
        }
        else 
        {
            require_once("pages/landing/index.php");
        }
    }
    
    // Biography
    else if ( $app == 'bio' )
    {
        if( $act == 'settings' )
        {
            require_once("pages/biography/settings.php");
        } 
        else {
            require_once("pages/biography/index.php");            
        }
        
    }
    
    // Info
    else if ( $app == 'info' )
    {
        if ( $act == 'new' ) 
        {
            require_once("pages/info/new.php");
            
        } 
        else if( $act == 'settings' )
        {
            require_once("pages/info/settings.php");
        }
        else 
        {
            require_once("pages/info/index.php");
        }        
    }
    
    // Contact Form
    else if ( $app == 'contact' )
    {
        if ( $type == 'categories' ) 
        {
            require_once("pages/contact/categories.php");
        }
        else if ( $act == 'settings' ) 
        {
            require_once("pages/contact/settings.php");
        }
        else 
        {
            require_once("pages/contact/index.php");
        }        
    }
    
    // Map
    else if ( $app == 'map' )
    {
        if ( $act == 'new' ) 
        {
            require_once("pages/map/new.php");
        }
        
        else if ( $act == 'settings' ) 
        {
            require_once("pages/map/settings.php");
        }
        
        else if ( $type == 'categories' )
        {
            if( $act == 'edit' )
            {
                require_once("pages/map/edit-category.php");
            }
            else
            {
                require_once("pages/map/categories.php");
            } 
                            
        }
        else 
        {
            require_once("pages/map/index.php");
        }
        
    }
    
    // Promotions
    else if ( $app == 'promotions' ) 
    {
        // Add Promotion
        if ( $act == 'new' )              
        {
            require_once("pages/promotions/new.php");
        }
        else if ( $act == 'settings' )
        {
            require_once("pages/promotions/settings.php");
        }
        else 
        {
            require_once("pages/promotions/index.php");
        }
    }
    
    // Resume
    else if ( $app == 'resume' )
    {
        if ( $act == 'settings' )
        {
            require_once("pages/resume/settings.php");
        }
        else 
        {
            require_once("pages/resume/index.php");
        }
    }
    
    // Products
    else if ( $app == 'products' ) 
    {
        // Products - Add product
        if( $act == "new" )
        {
            require_once("pages/products/new.php");
        }
        else if( $type == "categories" )
        {
            require_once("pages/products/categories.php");
        }
         else if( $type == "home" )
        {
            require_once("pages/products/home.php");
        }
        else 
        {
            require_once("pages/products/index.php");
        }
    }
    
    // Video Contest
    else if ( $app == 'video_contest' )
    {
        require_once("pages/video_contest/index.php");
    }
    
    // Photo Contest
    else if ( $app == 'photo_contest' )
    {
        require_once("pages/photo_contest/index.php");
    }
    
    // Video Gallery
    else if ( $app == 'videos' )
    {
        if ( $act == 'new' )              
        {
            require_once("pages/videos/new.php");
        }
        else if ( $act == 'settings' )              
        {
            require_once("pages/videos/settings.php");
        }
        else if ( $act == 'sort' )              
        {
            require_once("pages/videos/sort.php");
        }
        else 
        {
            require_once("pages/videos/index.php");
        }
    }
        
    // Trivia 
    else if( $app == 'trivia' ) 
    {
        // Contest Archive
        if ( $status == 'archive' )              
        {
            require_once("pages/trivia/archive.php");
        }
        // Add New Contest
        else if ( $act == 'new' )              
        {
            require_once("pages/trivia/new.php");
        }
        // Current Contest
        else 
        {
            require_once("pages/trivia/index.php");   
        }
        
    } 

    // TAG Contest
    else if ( $app == 'tag' ) 
    {
        require_once("pages/tag/index.php");
    }
    
    // Status Contest
    else if ( $app == 'status' ) 
    {
        require_once("pages/status/index.php");
    }
    
    // Text Contest
    else if ( $app == 'text_contest' ) 
    {
        require_once("pages/text_contest/index.php");
    }
    
    // Invite Friends
    else if ( $app == 'invite_friends' ) 
    {
        require_once("pages/invite_friends/index.php");
    }

    // News
    else if ( $app == 'news' )
    {
        // News - Categories
        if( $type == 'categories' )
        {
            if( $act == 'edit' )
            {
                require_once("pages/news/edit-category.php");
            }
            else 
            {
                require_once("pages/news/categories.php");
            }
            
        }
        // News - Settings
        else if ( $act == 'settings' )
        {
            require_once("pages/news/settings.php");
        }        
        // News - Add New
        else if ( $act == 'new' )
        {
            require_once("pages/news/new.php");
        }
        // News - Edit News
        else if ( $act == 'edit' )
        {
            require_once("pages/news/edit.php");
        }
        // News List
        else 
        {
            require_once("pages/news/index.php");    
        }
        
    }
    else 
    {
      require_once("pages/main.php");
    }
	
	require_once("pages/footer.php");
}
